package com.yyh.BookLendSystem.biz;

import java.sql.SQLException;

import com.yyh.BookLendSystem.dao.BookDao;
import com.yyh.BookLendSystem.dao.LeadDao;
import com.yyh.BookLendSystem.util.Utils;

public class LeadBiz {
	private LeadDao dao= new LeadDao();
	private BookDao bookDao =new BookDao();
	public boolean lead(Object rid,Object bid ,String name) throws BizException {
		Utils.check(Utils.isEmpty(rid), "请确认借书人");
		Utils.check(Utils.isEmpty(bid), "请选择要借出的图书");
		try {
			Integer nums = Integer.valueOf(bookDao.select(name.toString(), null, null).get(0).get("NUMS").toString().trim());
			if(nums>0) {
				dao.insert(rid,bid);
				dao.lend(name);
				return true;
			}else {
				return false;
			}
			
		} catch (SQLException e) {
			
			e.printStackTrace();
			throw new BizException("系统业务异常,请联系客服",e);
		}
	}
}
